<script setup lang="ts">
import { CircleCloseFilled } from "@element-plus/icons-vue";
import { ref } from "vue";
import {
  processDefineComplexInfo,
  ProcessDefineVO,
  processDefineGetVO
} from "@/api/flowable";
import { ObjectKeyValue } from "@/api/index";

defineProps({
  query: Function
});

const visible = ref<boolean>(false);

const info = ref<ProcessDefineVO>();

const showColumns = ref<Array<ObjectKeyValue>>();

const open = async (id: string) => {
  const res = await processDefineComplexInfo({ id });
  if (res.success) {
    visible.value = true;
    info.value = res.data;
  }
};

const initShowColumns = async () => {
  const res = await processDefineGetVO();
  if (res.success) {
    showColumns.value = res.data;
  }
};

initShowColumns();

defineExpose({
  open
});
</script>

<template>
  <el-drawer v-model="visible" size="70%" :show-close="false">
    <template #header="{ close, titleId, titleClass }">
      <h4 align="left" :id="titleId" :class="titleClass">流程详情</h4>
      <el-button type="danger" @click="close">
        <el-icon class="el-icon--left">
          <CircleCloseFilled />
        </el-icon>
        关闭
      </el-button>
    </template>
    <el-descriptions title="基础信息">
      <el-descriptions-item
        v-for="item in showColumns"
        :key="item.api"
        :label="item.name"
        >{{ info[item.api] }}</el-descriptions-item
      >
    </el-descriptions>
  </el-drawer>
</template>

<style></style>
